#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5009;
ll n;
ll S[maxn];
ll pekora[maxn];
ll ans = 0;
ll solve() {
  for(int i=0; i<n; ++i) {
    ll put = S[i] - pekora[i] - 1;
    if(put>0) {
      pekora[i]+=put;
      ans += put;
    }
    for(int j=i+2; j<=min(i+S[i], n); ++j) {
      pekora[j]++;
    }
    pekora[i+1] += pekora[i]-(S[i]-1);       // 没跳完的pekora
  }
  return ans;
}
void reset() {
  ans = 0;
  memset(pekora, 0, sizeof pekora);
}
int main() {
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  #endif
  int tc; cin>>tc;
  while(tc--) {
    reset();
    cin>>n;
    for(int i=0; i<n; ++i)cin>>S[i];
    cout<<solve()<<'\n';
  }
}